/services/games

  • module
services/games

{function()}

 

GET /services/games

Gets games from the database.

GET /services/games?
    where[tournamentId]=5&
    withRelated[]=homeTeam&withRelated[]=awayTeam&
    sortBy=round

Parameters

  1. where {Object}Optional

    Clause used to filter which games are returned.

  2. withRelated {Array}Optional

    Clause used to add related data.

  3. sortBy {String}Optional

    Clause used to sort the returned games.

Returns

{connectData}

An object that contains the games:

{data: [{
  id: Int,
  tournamentId: Int,
  round: String,
  court: String,
  videoUrl: String,
  homeTeamId: Int,
  awayTeamId: Int
}, ...]}

POST /services/games

Creates a game in the database. Only admins are allowed to create games.

POST /services/games
     {
       "tournamentId": 1,
       "round": 'Final',
       "court": 'Old court',
       "videoUrl": '?v=2141232213',
       "homeTeamId": 1
       "awayTeamId": 1
     }

Parameters

  1. JSONBody {JSON}

    The raw JSON properties of a game object

Returns

{JSON}

Returns JSON with all the properties of the newly created object, including its id.

{
  "id": 9,
  "tournamentId": 1,
  "round": 'Final',
  "court": 'Old court',
  "videoUrl": '?v=2141232213',
  "homeTeamId": 1
  "awayTeamId": 1
}

GET /services/games/:id

Gets a game by id from the database

GET /services/games/9?
    withRelated[]=homeTeam

Parameters

  1. withRelated {Array}Optional

    Clause used to add related data.

Returns

{JSON}

An object that contains the game data:

{
  id: Int,
  tournamentId: Int,
  round: String,
  court: String,
  videoUrl: String,
  homeTeamId: Int,
  awayTeamId: Int
}

PUT /services/games/:id

Updates a game in the database. Only admins are allowed to update games.

PUT /services/games/9
    {
      "tournamentId": 1,
      "round": 'Final',
      "court": 'New court',
      "videoUrl": '?v=2141232213',
      "homeTeamId": 1
      "awayTeamId": 1
    }

Parameters

  1. JSONBody {JSON}

    The updated properties of the game object

Returns

{JSON}

Returns JSON with all the properties of the updated object, including its id.

{
  "id": 9,
   "tournamentId": 1,
   "round": 'Final',
   "court": 'New court',
   "videoUrl": '?v=2141232213',
   "homeTeamId": 1
   "awayTeamId": 1
}

DELETE /services/games

Deletes a game in the database. Only admins are allowed to delete games.

DELETE /services/games/9

Returns

{JSON}

Returns an empty JSON object.

{}